package com.example.leetcode.tree;

import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution1325 {
    public TreeNode removeLeafNodes(TreeNode root, int target) {
        return TreeUtils.removeLeafNodes(root, target);
    }
}

public class leetcode1325 {
    public static void main(String[] args) {
        Solution1325 solution1325 = new Solution1325();
        Integer[] nums = {1, 2, 3, 2, null, 2, 4};
        Integer[] nums1 = {1, 3, 3, 3, 2};
        Integer[] nums2 = {1, 2, null, 2, null, 2};
        Integer[] nums3 = {1, 1, 1};
        Integer[] nums4 = {1, 2, 3};
        test1325(solution1325, nums, 2);
        test1325(solution1325, nums1, 3);
        test1325(solution1325, nums2, 2);
        test1325(solution1325, nums3, 1);
        test1325(solution1325, nums4, 1);
    }

    private static void test1325(Solution1325 solution1325, Integer[] nums, int target) {
        TreeNode root = solution1325.removeLeafNodes(TreeUtils.generateLeetcodeTree(nums), target);
        System.out.println(TreeUtils.getLeetcodeTreeVals(root));
    }
}
